package chapter2.No2_3_volatile关键字.f原子类也并不完全安全;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * !
 *
 * @author liujian
 * @version 2016/11/16 0016
 */
public class ServiceClass {

    AtomicInteger count = new AtomicInteger(0);

    public AtomicInteger getCount() {
        return count;
    }

    public void setCount(AtomicInteger count) {
        this.count = count;
    }

    // synchronized
    public void addCount() {
        System.out.println(Thread.currentThread().getName()+" 加了100之后的值是："+count.addAndGet(100));
        count.addAndGet(1);
    }
}
